package org.example.translate_braille.controller;


import com.alibaba.fastjson.JSONObject;
import org.example.translate_braille.entity.Photo;
import org.example.translate_braille.entity.Record;
import org.example.translate_braille.resdata.X;
import org.example.translate_braille.service.PhotoService;
import org.example.translate_braille.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Jacky
 * @since
 */
@RestController
@RequestMapping("/translate_braille/record")
public class RecordController {
    @Autowired
    RecordService recordService;

    @PostMapping("/inOrUpRecord")
    public X<Record> inOrUpRecord(@RequestBody JSONObject pic){
        String openId = pic.getString("openid");
        String content = pic.getString("content");
        Record record = new Record();
        record.setUserId(openId);
        record.setContent(content);
        return recordService.inOrUpRecord(record);
    }

    @PostMapping("/showRecordList")
    public X<Record> showRecordList(@RequestBody JSONObject jsonObject){
        String openId = jsonObject.getString("openid");
        return recordService.showRecordList(openId);
    }
}

